<?php
$isReloadable = true;
require_once("../../../pers/inc.config.php");
require_once('../../_inc/inc.session.php');
require_once('../../_inc/funct.html.php');

$aWhere = array();
if (reqVar('pagifilt')!='') {
	$aWhere[] = " (t.descr LIKE '%".addslashes(reqVar('pagifilt'))."%' "
		." OR t.cod_tabella LIKE '%".addslashes(reqVar('pagifilt'))."%') ";
}
$sWhere = (count($aWhere)==0)? "":" WHERE ".implode(" AND ",$aWhere);
$sql_sel = "SELECT count(*) AS num_rec " .
		" FROM rgl_tabelle t " .$sWhere;
//dbg_($sql_sel);
$objDB->query($sql_sel,'selRec');
$acRec = $objDB->fetch('selRec');
$numRec = $acRec['num_rec'];
$link = $_SERVER['PHP_SELF']."?".$sXSNQS;
$startOffset = 0;
$endOffset = 0;
$sFiltro = rglGetFiltro($link);
$sPaginaz = rglGetPaginaz($link, $numRec, $startOffset, $endOffset);

$sql_sel = "SELECT t.*" .
		" FROM rgl_tabelle t " .
		" ORDER BY t.cod_tabella ".
		" LIMIT ".$startOffset.",".($endOffset-$startOffset);
$objDB->query($sql_sel,'selRec');

$cmdL = "";
if (true) {
	$cmdR = "&nbsp;&nbsp;&nbsp;";
	$cmdR .= "<a class=\"cmd1\" href=\"tabelleIns.php?$sXSNQS\">nuova tabella</a>"; 
}
$cmdR .= cmdTorna(); 

testaHtml('Gestione applicazione',$msgPag,'gest');
echo getHtmlForm();
echo getHtmlHidden('xsn',XSN);
echo getHtmlHidden('startoffset');
?>
<table class="cmd1" border="0" cellpadding="3" cellspacing="1" width="100%" align='center'>
   <tr>
      <td class="cmd1" align="left">
         <?=$cmdL?>
      </td>
      <td class="cmd1" align="right">
         <?=$cmdR?>
      </td>
   </tr>
   <tr>
      <td class="cmd1" align="left">
			<?=$sFiltro?>
      </td>
      <td class="cmd1" align="right">
			<?=$sPaginaz?>
      </td>
   </tr>
</table>
<table class="tab1" border="0" cellpadding="3" cellspacing="1" width="100%" align='center'>
   <tr>
      <td class="lab1" width='10%' align='center'>Codice</td>
      <td class="lab1" width='40%' align='center'>Descrizione</td>
      <td class="lab1" width='50%' align='center'>Nota</td>
   </tr>
<? 
$clRF = 'txt2';
while($acRec = $objDB->fetch('selRec')) { 
	$clRF = ($clRF=='txt1')?'txt2':'txt1';	
?>
   <tr>
      <td class="<?=$clRF?>">
      	<a href='tabelleView.php?id=<?=$acRec['id_tabella']."&$sXSNQS"?>' class="<?=$clRF?>"
      	 	style='font-family:lucida console,courier;'>
            <?
            echo $acRec['cod_tabella'];
            ?>
         </a>
      </td>
      <td class="<?=$clRF?>">
            <? echo $acRec['descr'];?>
      </td>
      <td class="<?=$clRF?>">
            <?
            echo getHtmlViewNote($acRec['nota']);
            ?>
      </td>
<? } ?>
</table>
<table class="cmd1" border="0" cellpadding="3" cellspacing="1" width="100%" align='center'>
   <tr>
      <td class="cmd1" align="left"></td>
      <td class="cmd1" align="right">
<?=$sPaginaz?>
      </td>
   </tr>
   <tr>
      <td class="cmd1" align="left">
         <?=$cmdL?>
      </td>
      <td class="cmd1" align="right">
         <?=$cmdR?>
      </td>
   </tr>
</table>
<?
echo "</form>\n";
codaHtml();
exit();

